package mobi.yuanshen.config;

import mobi.yuanshen.interceptor.LoginCheckInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private LoginCheckInterceptor loginCheckInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry
                .addInterceptor(loginCheckInterceptor) // 添加拦截器
                //设置拦截器拦截的请求路径（ /** 表示拦截所有请求）
                .addPathPatterns("/**")
                // 不拦截的资源路径
                .excludePathPatterns("/login");
    }
}
